import Vue from 'vue'
import Router from 'vue-router'
import loginPage from '../components/Login'
import shoesList from '../components/ShoesList'
import productIdManage from '../components/ProductIdManage'
import hasUploadImageList from '../components/HasUploadImageList'

Vue.use(Router)

//获取原型对象上的push函数
const originalPush = Router.prototype.push
//修改原型对象中的push方法
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


const routes = [
  {
    path: '/',
    name: 'HelloWorld',
    component: loginPage
  },
  {
    path: '/login',
    name: 'loginPage',
    component: loginPage
  },
  {
    path: '/shoesList',
    name: 'shoesList',
    component: shoesList,
    children: [
      {
        path: '/productIdManage',
        name: 'productIdManage',
        component: productIdManage,
      }
    ]
  },
  {
    path: '/hasUploadImageList',
    name: 'hasUploadImageList',
    component: hasUploadImageList,
  },






  ]

const router = new Router({
  //配置路由和组件之间的应用关系
  routes,            //将routes传入router里使用
  mode: "history",    //链接地址中不再显示#号，显示方式为window.history模式
})

//将router对象传出，即可在vue实例中使用
export default router
